package org.example.enump;

/**
 * @version: 1
 * @description: java
 * @author: java
 * @create: 2020-06-03 17:32
 **/
public class EnumDemo {

    public static void main(String[] args) {
        for (Color value : Color.values()) {
            System.out.println("具体的实例：" + value);
            System.out.println("实例的名称：" + value.name());
            System.out.println("实例的声明次序：" + value.ordinal());
            System.out.println("返回实例所属的enum实例：" + value.getDeclaringClass());
            System.err.println(value.getIndex() + " : " + value.getName());
        }
        Color red = Color.RED;
        System.err.println(red.compareTo(Color.GREEN));

    }
}

enum Color {
    RED("红色", 1), GREEN("绿色", 3), BLUE("蓝色", 5);
    private String name;
    private int index;

    Color(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }
}
class TrafficLight {
}

